// Person.java
package fingergame;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Person {
    private String name;
    private int score;
    private int HP;
    private List<Card> cards;

    public Person(String name) {
        this.name = name;
        this.score = 0;
        this.HP = 100;
        this.cards = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            int randomType = (int) (Math.random() * 3) + 1;
            String type = "";
            switch (randomType) {
                case 1:
                    type = "剪刀";
                    break;
                case 2:
                    type = "石头";
                    break;
                case 3:
                    type = "布";
                    break;
            }
            Card card = new Card(type);
            cards.add(card);
            System.out.println(name + "获得卡牌：" + card.getType());
        }
    }

    public String getName() {
        return name;
    }

    public int getHP() {
        return HP;
    }

    public void decreaseHP(int amount) {
        HP -= amount;
    }

    public Card chooseCard() {
        Scanner scanner = new Scanner(System.in);
        System.out.println(name + "的剩余卡牌：");
        for (Card card : cards) {
            System.out.print(card.getType() + " ");
        }
        System.out.println();
        System.out.println(name + "请选择一张卡牌（剪刀/石头/布）：");
        String type = scanner.nextLine();
        for (int i = 0; i < cards.size(); i++) {
            if (cards.get(i).getType().equals(type)) {
                return cards.remove(i);
            }
        }
        return null; // 如果玩家选择了不存在的卡牌，返回 null
    }

    // Other methods...
}
